﻿#region References
using System.Collections.Generic;
using System.Globalization;
using System.Web;
using App_Code.Objects;
using DotNetOpenAuth.OpenId.RelyingParty;
using VisualCronAPI;

#endregion

namespace App_Code.Helpers
{
    public class PageHelper
    {
        #region Constants

        private const string VISUALCRON_SESSION_DATA_KEY = "VISUALCRON_SESSION_DATA_KEY";
        private const string OPENID_AUTHENTICATION_KEY = "OPENID_AUTHENTICATION_KEY";
        #endregion

        #region Properties
        public static VisualCronSession VisualCronSession
        {
            get
            {
                if (HttpContext.Current == null || HttpContext.Current.Session == null || HttpContext.Current.Session[VISUALCRON_SESSION_DATA_KEY] == null)
                {
                    return null;
                }

                return (VisualCronSession)HttpContext.Current.Session[VISUALCRON_SESSION_DATA_KEY];

            }

            set
            {
                if (HttpContext.Current == null || HttpContext.Current.Session == null)
                {
                    return;
                }

                HttpContext.Current.Session[VISUALCRON_SESSION_DATA_KEY] = value;
            }
        }

        public static CultureInfo CurrentUserDateTimeFormat()
        {
            CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentUICulture;
            return ci;
        }

        public static OpenIdEventArgs CurrentUserOpenId
        {
            get
            {
                if (HttpContext.Current == null || HttpContext.Current.Session == null || HttpContext.Current.Session[OPENID_AUTHENTICATION_KEY] == null)
                {
                    return null;
                }

                return (OpenIdEventArgs)HttpContext.Current.Session[OPENID_AUTHENTICATION_KEY];

            }

            set
            {
                if (HttpContext.Current == null || HttpContext.Current.Session == null)
                {
                    return;
                }

                HttpContext.Current.Session[OPENID_AUTHENTICATION_KEY] = value;
            }
        }


        #endregion
    }
}